package com.yq.homework.day281;

import java.util.concurrent.TimeUnit;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/28 19:29
 * 有3个线程,T1,T2,T3,
 * 保证T1线程先执行，
 * T2在T1之后执行,T3在T2执行完后执行？
 * 利用线程控制API
 */
public class Demo01 {

    public static void main(String[] args) throws InterruptedException {
        MyThread t1 = new MyThread("T1");
        MyThread t2 = new MyThread("T2");
        MyThread t3 = new MyThread("T3");
        t1.start();
        t1.join();
        t2.start();
        t2.join();
        t3.start();

    }

}

class MyThread extends Thread{
    public MyThread(String name) {

        super(name);
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(getName()+"=====正在执行"+i);

        }
    }
}